<template>
  <div>
    <custom-table
      :columns="columns"
      :query="queryParams"
      :head-btn="headBtn"
      :row-btn="rowBtn"
      v-bind="$attrs"
      v-on="listeners"
      :show-row-btn="[]"
      :hideRowBtn="hideRowBtn"
      :toolFixed="false"
      :hiddenHeadBtn="hiddenHeadBtn"
      @tap-head-btn="onTapHeadBtn"
      @tap-row-btn="onTapRowBtn"
      @row-dblclick="onRowDbClick"
    >
    <!-- <template v-slot:address="{row}">
      <div style="color:red; background-color: aqua;">{{row.address}}内容</div>
    </template> -->
    </custom-table>
  </div>

</template>

<script>
import tableMixin from '@/utils/mixin/custom-table'
import mock from '@/utils/mixin/mock'
import { showLoading, hideLoading } from '@/utils'
import curd from '@/api/curd'
export default {
  data() {
    return {
      headBtn: [
        // {
        //   name: '刷新权限',
        //   // 类型
        //   type: 'primary',
        //   // 图标
        //   icon: 'el-icon-refresh-right',
        //   // 权限
        //   auth: this.getFullAuth('flush'),
        //   key: 'flushAuth'
        // }
      ],
      columns: []
      // columns: [
      //   { name: '名称', field: 'real_name', width: 150, required: true },
      //   { name: '手机号', field: 'tel', width: 150 },
      //   // { name: '图片', field: 'image', type: 'image', width: 150 },
      //   // { name: '链接', field: 'link', type: 'link', width: 150 },
      //   // { name: '状态', field: 'status', label: true, type: this.checkAuth('change') ? 'switch' : 'tag', opts: {} },
      //   { name: '添加时间', field: 'create_time' }
      // ]
    }
  },
  components: {},
  mixins: [
    tableMixin, mock
  ],
  computed: {
    rowBtn() {
      return [
        {
          name: '移除',
          key: 'notice',
          confirm: '确认移除{real_name}租户吗',
          mode: 'pop'
          // show(row) {
          //   return row.status === '待缴费'
          // }
        }
      ]
    }
  },
  props: {
    arr: {
      type: Object
    },
    column: {
      type: Array
    },
    hiddenHeadBtn: {
      type: Boolean,
      default: true
    },
    hideRowBtn: {
      type: Boolean,
      default: false
    },
    room_id: {
      type: Number,
      default: 0
    }
  },
  filters: {},
  created() {

  },
  methods: {
    onLoad() {
      var that = this
      // console.log('我是arr', JSON.parse(sessionStorage.getItem('arr')))
      console.log('arr是我呢', this.arr)
      console.log('column是我呢', this.column)
      setTimeout(() => {
        console.log('table_$attrs', this.$attrs)
        console.log('table_listeners', this.listeners)
      }, 2000)
      that.setMockData(this.arr)
      that.columns = this.column
    },
    // 移除租户
    onTapRowBtnNotice(...e) {
      var that = this
      console.log('e', e)

      e[0]['room_id'] = this.room_id
      console.log('确认移除吗', e)
      var data = {
        room_id: that.room_id,
        id: e[0].id
      }
      // data['room_id'] = this.room_id

      showLoading('移除中...')
      curd('roomLeaseRecord').post('removeUser', data).then(res => {
        hideLoading()
        console.log('移除结果', res)
        // this.onTapHeadBtnFlush({})
        console.log('list', this.list)
        this.list.splice(e[1], 1)
      }, hideLoading)
      // that.curd.post('roomLeaseRecord/removeUser', data).then(res => {
      //   hideLoading()
      //   console.log('移除结果', res)
      //   // var arr = ({ list: res.data })
      //   // that.tableData = arr
      //   // this.Visible = true
      //   // this.onTapHeadBtnFlush({})
      // }, hideLoading)
    }
  }
}
</script>

<style lang="scss">
.tool-box{
  width: 80%;
}
</style>
